package cn.eric.framework.exception.domain.exception;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;

/**
 * 业务异常
 */
@XmlAccessorType(XmlAccessType.NONE)
public class BusinessException extends RuntimeException {
    @XmlAttribute(name = "id")
    private int id;
    @XmlAttribute(name = "info")
    private String info;
    private String additionalInfo;

    public BusinessException() {
        super();
    }

    /**
     * 业务代码使用的生成业务异常的构造方法
     *
     * @param id
     */
    public BusinessException(int id) {
        super();
        this.id = id;
    }

    /**
     * 用于携带附加信息的的业务异常
     *
     * @param id
     * @param additionalInfo
     */
    public BusinessException(int id, String additionalInfo) {
        super();
        this.id = id;
        this.additionalInfo = additionalInfo;
    }

    @Override
    public String toString() {
        return "BusinessException{" +
                "id=" + id +
                ", info='" + info + '\'' +
                ", additionalInfo='" + additionalInfo + '\'' +
                '}';
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public String getAdditionalInfo() {
        return additionalInfo;
    }

    public void setAdditionalInfo(String additionalInfo) {
        this.additionalInfo = additionalInfo;
    }
}
